/*oOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoO*/
/*
Authors: Ram Ovadia 201374022 and Lior Fass 300069705
Project: HW Assignment 3
Description: This is the header of the BaggageTracker main().  
*/
/*oOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoO*/

#include "BaggageTrackerUtils.h"

/*
* Main function of baggage tracker project
* this function gets argc and argv from the user and passes them to the main functions
* the input checker, the init the dispatcher ther output file generator and the program finalizer
*
* Input:
* -----
* argc - num of input arguments
* argv - input arguments
*
* Output:
* -----
* Return Value:
* 0 - successful.  
* !0 - failure. 
*/
int main (int argc, char *argv[])
{
	FILE *in_f;
	FILE *out_f;
	int num_of_slots = 0;
	int num_of_sorters = 0;
	tArgs *common = NULL;
	int return_value = 1;

	if (input_check(argc, argv, &num_of_slots, &num_of_sorters, &in_f, &out_f) != 1)
	{	
		common = init(num_of_slots, num_of_sorters, in_f); 
		if (common != NULL)
		{
			if (dispatcher(common, num_of_sorters) != 1)
			{
				output_generate(common, out_f);
				return_value = 0;
			}
		}
	}
	finalize_run(common, out_f, in_f);

	return return_value;
}
